<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>克隆节点</title>
    <style>
        .child{
            width: 100px;
            height: 100px;
            margin: 10px;
            background-color: red;
        }
    </style>
    <script>
        window.onload=function(){
            // 1.获取父节点
            var parent=document.getElementsByClassName('parent')[0];
            // 2.获取要复制的节点
            var three=parent.children[2];
            // 3.进行复制
            // 浅克隆 只复制节点 不复制节点内容
            var cloneThree=three.cloneNode();
            // 深克隆 既复制节点也复制节点内容
            var cloneThree1=three.cloneNode(true); 
            // 4.追加给父节点
            parent.appendChild(cloneThree);
            parent.appendChild(cloneThree1);
        }
    </script>
</head>
<body>
    <div class="parent">
        <div class="child">one</div>
        <div class="child">two</div>
        <div class="child">three</div>
    </div>
</body>
</html>